home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d21 / dvglue10.arc / TVFREE.C < prev    next >
C/C++ Source or Header  |  1988-08-13  |  1KB  |  36 lines

  1. /*================================================*/
  2. /* TVFREE.C                                       */
  3. /*                                                */
  4. /* (c) Copyright 1988 Ralf Brown                  */
  5. /*     All Rights Reserved                        */
  6. /* May be freely copied for noncommercial use as  */
  7. /* long as this copyright notice is kept intact   */
  8. /* and any changes are indicated in the comment   */
  9. /* blocks for the functions                       */
  10. /*================================================*/
  11.  
  12. #include "tvapi.h"
  13.  
  14. #undef free
  15.  
  16. /*================================================*/
  17.  
  18. extern OBJECT _TV_alloc_mutex_ ;
  19.  
  20. /*================================================*/
  21. /* _TV_free   version of free() which is safe in  */
  22. /*            the presence of multiple threads    */
  23. /*   Ralf Brown 5/10/88                           */
  24. /*================================================*/
  25.  
  26. void _TV_free(void *block)
  27. {
  28.    if (!TVisobj(_TV_alloc_mutex_))
  29.       _TV_alloc_mutex_ = TVmbx_new() ;
  30.    TVlock(_TV_alloc_mutex_) ;  /* make sure we only have one thread at a time */
  31.    free(block) ;               /* in the memory allocation routines */
  32.    TVunlock(_TV_alloc_mutex_) ;
  33. }
  34.  
  35. /* End of TVFREE.C */
  36.